package org.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.util.Result;
import org.example.domain.Type;
import org.example.service.TypeService;
import org.example.mapper.TypeMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author 86150
* @description 针对表【t_type】的数据库操作Service实现
* @createDate 2024-07-10 14:23:10
*/
@Service
public class TypeServiceImpl extends ServiceImpl<TypeMapper, Type>
    implements TypeService{
@Resource
private TypeMapper typeMapper;
    @Override
    public Boolean updateNum(Integer tid, Integer num) {
        Type type = typeMapper.selectById(tid);
        if(type!=null){
            if(type.getAmount()>num){
                type.setAmount(type.getAmount()+num);
                typeMapper.updateById(type);
                return true;
            }
        }
        return false;
    }
}




